
_init:     file format elf32-i386


Disassembly of section .text:

00000000 <main>:

char *argv[] = { "sh", 0 };

int
main(void)
{
   0:	55                   	push   %ebp
   1:	89 e5                	mov    %esp,%ebp
   3:	53                   	push   %ebx
   4:	83 e4 f0             	and    $0xfffffff0,%esp
   7:	83 ec 10             	sub    $0x10,%esp
  int pid, wpid;

  if(open("console", O_RDWR) < 0){
   a:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  11:	00 
  12:	c7 04 24 86 07 00 00 	movl   $0x786,(%esp)
  19:	e8 96 03 00 00       	call   3b4 <open>
  1e:	85 c0                	test   %eax,%eax
  20:	0f 88 ac 00 00 00    	js     d2 <main+0xd2>
    mknod("console", 1, 1);
    open("console", O_RDWR);
  }
  dup(0);  // stdout
  26:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  2d:	e8 ba 03 00 00       	call   3ec <dup>
  dup(0);  // stderr
  32:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  39:	e8 ae 03 00 00       	call   3ec <dup>
  3e:	66 90                	xchg   %ax,%ax

  for(;;){
    printf(1, "init: starting sh\n");
  40:	c7 44 24 04 8e 07 00 	movl   $0x78e,0x4(%esp)
  47:	00 
  48:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  4f:	e8 6c 04 00 00       	call   4c0 <printf>
    pid = fork();
  54:	e8 13 03 00 00       	call   36c <fork>
    if(pid < 0){
  59:	83 f8 00             	cmp    $0x0,%eax
  dup(0);  // stdout
  dup(0);  // stderr

  for(;;){
    printf(1, "init: starting sh\n");
    pid = fork();
  5c:	89 c3                	mov    %eax,%ebx
    if(pid < 0){
  5e:	7c 2c                	jl     8c <main+0x8c>
      printf(1, "init: fork failed\n");
      exit();
    }
    if(pid == 0){
  60:	74 43                	je     a5 <main+0xa5>
  62:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
      exec("sh", argv);
      printf(1, "init: exec sh failed\n");
      exit();
    }
    while((wpid=wait()) >= 0 && wpid != pid)
  68:	e8 0f 03 00 00       	call   37c <wait>
  6d:	85 c0                	test   %eax,%eax
  6f:	90                   	nop
  70:	78 ce                	js     40 <main+0x40>
  72:	39 d8                	cmp    %ebx,%eax
  74:	74 ca                	je     40 <main+0x40>
      printf(1, "zombie!\n");
  76:	c7 44 24 04 cd 07 00 	movl   $0x7cd,0x4(%esp)
  7d:	00 
  7e:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  85:	e8 36 04 00 00       	call   4c0 <printf>
  8a:	eb dc                	jmp    68 <main+0x68>

  for(;;){
    printf(1, "init: starting sh\n");
    pid = fork();
    if(pid < 0){
      printf(1, "init: fork failed\n");
  8c:	c7 44 24 04 a1 07 00 	movl   $0x7a1,0x4(%esp)
  93:	00 
  94:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  9b:	e8 20 04 00 00       	call   4c0 <printf>
      exit();
  a0:	e8 cf 02 00 00       	call   374 <exit>
    }
    if(pid == 0){
      exec("sh", argv);
  a5:	c7 44 24 04 88 0a 00 	movl   $0xa88,0x4(%esp)
  ac:	00 
  ad:	c7 04 24 b4 07 00 00 	movl   $0x7b4,(%esp)
  b4:	e8 f3 02 00 00       	call   3ac <exec>
      printf(1, "init: exec sh failed\n");
  b9:	c7 44 24 04 b7 07 00 	movl   $0x7b7,0x4(%esp)
  c0:	00 
  c1:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  c8:	e8 f3 03 00 00       	call   4c0 <printf>
      exit();
  cd:	e8 a2 02 00 00       	call   374 <exit>
main(void)
{
  int pid, wpid;

  if(open("console", O_RDWR) < 0){
    mknod("console", 1, 1);
  d2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  d9:	00 
  da:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  e1:	00 
  e2:	c7 04 24 86 07 00 00 	movl   $0x786,(%esp)
  e9:	e8 ce 02 00 00       	call   3bc <mknod>
    open("console", O_RDWR);
  ee:	c7 44 24 04 02 00 00 	movl   $0x2,0x4(%esp)
  f5:	00 
  f6:	c7 04 24 86 07 00 00 	movl   $0x786,(%esp)
  fd:	e8 b2 02 00 00       	call   3b4 <open>
 102:	e9 1f ff ff ff       	jmp    26 <main+0x26>
 107:	90                   	nop
 108:	90                   	nop
 109:	90                   	nop
 10a:	90                   	nop
 10b:	90                   	nop
 10c:	90                   	nop
 10d:	90                   	nop
 10e:	90                   	nop
 10f:	90                   	nop

00000110 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 110:	53                   	push   %ebx
 111:	8b 44 24 08          	mov    0x8(%esp),%eax
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 115:	31 d2                	xor    %edx,%edx
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
 117:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
 11b:	90                   	nop
 11c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 120:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
 124:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 127:	83 c2 01             	add    $0x1,%edx
 12a:	84 c9                	test   %cl,%cl
 12c:	75 f2                	jne    120 <strcpy+0x10>
    ;
  return os;
}
 12e:	5b                   	pop    %ebx
 12f:	c3                   	ret    

00000130 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 130:	56                   	push   %esi
 131:	53                   	push   %ebx
 132:	8b 4c 24 0c          	mov    0xc(%esp),%ecx
 136:	8b 54 24 10          	mov    0x10(%esp),%edx
  while(*p && *p == *q)
 13a:	0f b6 01             	movzbl (%ecx),%eax
 13d:	0f b6 1a             	movzbl (%edx),%ebx
 140:	84 c0                	test   %al,%al
 142:	74 24                	je     168 <strcmp+0x38>
 144:	38 d8                	cmp    %bl,%al
 146:	74 11                	je     159 <strcmp+0x29>
 148:	eb 2e                	jmp    178 <strcmp+0x48>
 14a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 150:	83 c1 01             	add    $0x1,%ecx
 153:	38 d8                	cmp    %bl,%al
 155:	75 21                	jne    178 <strcmp+0x48>
    p++, q++;
 157:	89 f2                	mov    %esi,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 159:	0f b6 41 01          	movzbl 0x1(%ecx),%eax
    p++, q++;
 15d:	8d 72 01             	lea    0x1(%edx),%esi
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 160:	0f b6 5a 01          	movzbl 0x1(%edx),%ebx
 164:	84 c0                	test   %al,%al
 166:	75 e8                	jne    150 <strcmp+0x20>
    p++, q++;
  return (uchar)*p - (uchar)*q;
 168:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 16b:	31 c0                	xor    %eax,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 16d:	29 d8                	sub    %ebx,%eax
}
 16f:	5b                   	pop    %ebx
 170:	5e                   	pop    %esi
 171:	c3                   	ret    
 172:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
    p++, q++;
  return (uchar)*p - (uchar)*q;
 178:	0f b6 db             	movzbl %bl,%ebx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
 17b:	0f b6 c0             	movzbl %al,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
 17e:	29 d8                	sub    %ebx,%eax
}
 180:	5b                   	pop    %ebx
 181:	5e                   	pop    %esi
 182:	c3                   	ret    
 183:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 189:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000190 <strlen>:

uint
strlen(char *s)
{
 190:	8b 4c 24 04          	mov    0x4(%esp),%ecx
  int n;

  for(n = 0; s[n]; n++)
 194:	31 c0                	xor    %eax,%eax
 196:	80 39 00             	cmpb   $0x0,(%ecx)
 199:	74 10                	je     1ab <strlen+0x1b>
 19b:	31 d2                	xor    %edx,%edx
 19d:	8d 76 00             	lea    0x0(%esi),%esi
 1a0:	83 c2 01             	add    $0x1,%edx
 1a3:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
 1a7:	89 d0                	mov    %edx,%eax
 1a9:	75 f5                	jne    1a0 <strlen+0x10>
    ;
  return n;
}
 1ab:	f3 c3                	repz ret 
 1ad:	8d 76 00             	lea    0x0(%esi),%esi

000001b0 <memset>:

void*
memset(void *dst, int c, uint n)
{
 1b0:	57                   	push   %edi
 1b1:	8b 54 24 08          	mov    0x8(%esp),%edx
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
 1b5:	8b 4c 24 10          	mov    0x10(%esp),%ecx
 1b9:	8b 44 24 0c          	mov    0xc(%esp),%eax
 1bd:	89 d7                	mov    %edx,%edi
 1bf:	fc                   	cld    
 1c0:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
 1c2:	89 d0                	mov    %edx,%eax
 1c4:	5f                   	pop    %edi
 1c5:	c3                   	ret    
 1c6:	8d 76 00             	lea    0x0(%esi),%esi
 1c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000001d0 <strchr>:

char*
strchr(const char *s, char c)
{
 1d0:	8b 44 24 04          	mov    0x4(%esp),%eax
 1d4:	0f b6 4c 24 08       	movzbl 0x8(%esp),%ecx
  for(; *s; s++)
 1d9:	0f b6 10             	movzbl (%eax),%edx
 1dc:	84 d2                	test   %dl,%dl
 1de:	74 1d                	je     1fd <strchr+0x2d>
    if(*s == c)
 1e0:	38 ca                	cmp    %cl,%dl
 1e2:	75 0e                	jne    1f2 <strchr+0x22>
 1e4:	eb 1c                	jmp    202 <strchr+0x32>
 1e6:	66 90                	xchg   %ax,%ax
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 1e8:	83 c0 01             	add    $0x1,%eax
    if(*s == c)
 1eb:	38 ca                	cmp    %cl,%dl
 1ed:	8d 76 00             	lea    0x0(%esi),%esi
 1f0:	74 0e                	je     200 <strchr+0x30>
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
 1f2:	0f b6 50 01          	movzbl 0x1(%eax),%edx
 1f6:	84 d2                	test   %dl,%dl
 1f8:	75 ee                	jne    1e8 <strchr+0x18>
    if(*s == c)
      return (char*) s;
  return 0;
 1fa:	31 c0                	xor    %eax,%eax
 1fc:	c3                   	ret    
 1fd:	31 c0                	xor    %eax,%eax
 1ff:	90                   	nop
}
 200:	f3 c3                	repz ret 
 202:	f3 c3                	repz ret 
 204:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 20a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00000210 <gets>:

char*
gets(char *buf, int max)
{
 210:	55                   	push   %ebp
 211:	57                   	push   %edi
 212:	56                   	push   %esi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 213:	31 f6                	xor    %esi,%esi
  return 0;
}

char*
gets(char *buf, int max)
{
 215:	53                   	push   %ebx
 216:	83 ec 2c             	sub    $0x2c,%esp
 219:	8b 7c 24 40          	mov    0x40(%esp),%edi
 21d:	8b 6c 24 44          	mov    0x44(%esp),%ebp
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 221:	eb 38                	jmp    25b <gets+0x4b>
 223:	90                   	nop
 224:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    cc = read(0, &c, 1);
 228:	8d 44 24 1f          	lea    0x1f(%esp),%eax
 22c:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 233:	00 
 234:	89 44 24 04          	mov    %eax,0x4(%esp)
 238:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 23f:	e8 48 01 00 00       	call   38c <read>
    if(cc < 1)
 244:	85 c0                	test   %eax,%eax
 246:	7e 1a                	jle    262 <gets+0x52>
      break;
    buf[i++] = c;
 248:	0f b6 44 24 1f       	movzbl 0x1f(%esp),%eax
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 24d:	89 de                	mov    %ebx,%esi
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 24f:	3c 0d                	cmp    $0xd,%al

  for(i=0; i+1 < max; ){
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
 251:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
 255:	74 0b                	je     262 <gets+0x52>
 257:	3c 0a                	cmp    $0xa,%al
 259:	74 07                	je     262 <gets+0x52>
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 25b:	8d 5e 01             	lea    0x1(%esi),%ebx
 25e:	39 eb                	cmp    %ebp,%ebx
 260:	7c c6                	jl     228 <gets+0x18>
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
      break;
  }
  buf[i] = '\0';
 262:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
 266:	83 c4 2c             	add    $0x2c,%esp
 269:	89 f8                	mov    %edi,%eax
 26b:	5b                   	pop    %ebx
 26c:	5e                   	pop    %esi
 26d:	5f                   	pop    %edi
 26e:	5d                   	pop    %ebp
 26f:	c3                   	ret    

00000270 <stat>:

int
stat(char *n, struct statt *st)
{
 270:	83 ec 1c             	sub    $0x1c,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 273:	8b 44 24 20          	mov    0x20(%esp),%eax
  return buf;
}

int
stat(char *n, struct statt *st)
{
 277:	89 5c 24 14          	mov    %ebx,0x14(%esp)
 27b:	89 74 24 18          	mov    %esi,0x18(%esp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
 27f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 284:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
 28b:	00 
 28c:	89 04 24             	mov    %eax,(%esp)
 28f:	e8 20 01 00 00       	call   3b4 <open>
  if(fd < 0)
 294:	85 c0                	test   %eax,%eax
stat(char *n, struct statt *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 296:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
 298:	78 1a                	js     2b4 <stat+0x44>
    return -1;
  r = fstat(fd, st);
 29a:	8b 44 24 24          	mov    0x24(%esp),%eax
 29e:	89 1c 24             	mov    %ebx,(%esp)
 2a1:	89 44 24 04          	mov    %eax,0x4(%esp)
 2a5:	e8 22 01 00 00       	call   3cc <fstat>
  close(fd);
 2aa:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
 2ad:	89 c6                	mov    %eax,%esi
  close(fd);
 2af:	e8 e8 00 00 00       	call   39c <close>
  return r;
}
 2b4:	89 f0                	mov    %esi,%eax
 2b6:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 2ba:	8b 74 24 18          	mov    0x18(%esp),%esi
 2be:	83 c4 1c             	add    $0x1c,%esp
 2c1:	c3                   	ret    
 2c2:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 2c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000002d0 <atoi>:

int
atoi(const char *s)
{
 2d0:	53                   	push   %ebx
 2d1:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  int n;

  n = 0;
 2d5:	31 c0                	xor    %eax,%eax
  while('0' <= *s && *s <= '9')
 2d7:	0f b6 11             	movzbl (%ecx),%edx
 2da:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2dd:	80 fb 09             	cmp    $0x9,%bl
 2e0:	77 1e                	ja     300 <atoi+0x30>
 2e2:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    n = n*10 + *s++ - '0';
 2e8:	0f be d2             	movsbl %dl,%edx
 2eb:	83 c1 01             	add    $0x1,%ecx
 2ee:	8d 04 80             	lea    (%eax,%eax,4),%eax
 2f1:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 2f5:	0f b6 11             	movzbl (%ecx),%edx
 2f8:	8d 5a d0             	lea    -0x30(%edx),%ebx
 2fb:	80 fb 09             	cmp    $0x9,%bl
 2fe:	76 e8                	jbe    2e8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
 300:	5b                   	pop    %ebx
 301:	c3                   	ret    
 302:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
 309:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000310 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
 310:	56                   	push   %esi
 311:	53                   	push   %ebx
 312:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 316:	8b 44 24 0c          	mov    0xc(%esp),%eax
 31a:	8b 74 24 10          	mov    0x10(%esp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 31e:	85 db                	test   %ebx,%ebx
 320:	7e 14                	jle    336 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
 322:	31 d2                	xor    %edx,%edx
 324:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
 328:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 32c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 32f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 332:	39 da                	cmp    %ebx,%edx
 334:	75 f2                	jne    328 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
 336:	5b                   	pop    %ebx
 337:	5e                   	pop    %esi
 338:	c3                   	ret    
 339:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000340 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 340:	56                   	push   %esi
 341:	53                   	push   %ebx
 342:	8b 5c 24 14          	mov    0x14(%esp),%ebx
 346:	8b 44 24 0c          	mov    0xc(%esp),%eax
 34a:	8b 74 24 10          	mov    0x10(%esp),%esi
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 34e:	85 db                	test   %ebx,%ebx
 350:	7e 14                	jle    366 <memcpy+0x26>
 352:	31 d2                	xor    %edx,%edx
 354:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    *dst++ = *src++;
 358:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
 35c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
 35f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
 362:	39 da                	cmp    %ebx,%edx
 364:	75 f2                	jne    358 <memcpy+0x18>

void *
memcpy(void *dst, const void *src, uint n)
{
  return memmove(dst, src, n);
}
 366:	5b                   	pop    %ebx
 367:	5e                   	pop    %esi
 368:	c3                   	ret    
 369:	90                   	nop
 36a:	90                   	nop
 36b:	90                   	nop

0000036c <fork>:
 36c:	b8 01 00 00 00       	mov    $0x1,%eax
 371:	cd 40                	int    $0x40
 373:	c3                   	ret    

00000374 <exit>:
 374:	b8 02 00 00 00       	mov    $0x2,%eax
 379:	cd 40                	int    $0x40
 37b:	c3                   	ret    

0000037c <wait>:
 37c:	b8 03 00 00 00       	mov    $0x3,%eax
 381:	cd 40                	int    $0x40
 383:	c3                   	ret    

00000384 <pipe>:
 384:	b8 04 00 00 00       	mov    $0x4,%eax
 389:	cd 40                	int    $0x40
 38b:	c3                   	ret    

0000038c <read>:
 38c:	b8 06 00 00 00       	mov    $0x6,%eax
 391:	cd 40                	int    $0x40
 393:	c3                   	ret    

00000394 <write>:
 394:	b8 05 00 00 00       	mov    $0x5,%eax
 399:	cd 40                	int    $0x40
 39b:	c3                   	ret    

0000039c <close>:
 39c:	b8 07 00 00 00       	mov    $0x7,%eax
 3a1:	cd 40                	int    $0x40
 3a3:	c3                   	ret    

000003a4 <kill>:
 3a4:	b8 08 00 00 00       	mov    $0x8,%eax
 3a9:	cd 40                	int    $0x40
 3ab:	c3                   	ret    

000003ac <exec>:
 3ac:	b8 09 00 00 00       	mov    $0x9,%eax
 3b1:	cd 40                	int    $0x40
 3b3:	c3                   	ret    

000003b4 <open>:
 3b4:	b8 0a 00 00 00       	mov    $0xa,%eax
 3b9:	cd 40                	int    $0x40
 3bb:	c3                   	ret    

000003bc <mknod>:
 3bc:	b8 0b 00 00 00       	mov    $0xb,%eax
 3c1:	cd 40                	int    $0x40
 3c3:	c3                   	ret    

000003c4 <unlink>:
 3c4:	b8 0c 00 00 00       	mov    $0xc,%eax
 3c9:	cd 40                	int    $0x40
 3cb:	c3                   	ret    

000003cc <fstat>:
 3cc:	b8 0d 00 00 00       	mov    $0xd,%eax
 3d1:	cd 40                	int    $0x40
 3d3:	c3                   	ret    

000003d4 <link>:
 3d4:	b8 0e 00 00 00       	mov    $0xe,%eax
 3d9:	cd 40                	int    $0x40
 3db:	c3                   	ret    

000003dc <mkdir>:
 3dc:	b8 0f 00 00 00       	mov    $0xf,%eax
 3e1:	cd 40                	int    $0x40
 3e3:	c3                   	ret    

000003e4 <chdir>:
 3e4:	b8 10 00 00 00       	mov    $0x10,%eax
 3e9:	cd 40                	int    $0x40
 3eb:	c3                   	ret    

000003ec <dup>:
 3ec:	b8 11 00 00 00       	mov    $0x11,%eax
 3f1:	cd 40                	int    $0x40
 3f3:	c3                   	ret    

000003f4 <getpid>:
 3f4:	b8 12 00 00 00       	mov    $0x12,%eax
 3f9:	cd 40                	int    $0x40
 3fb:	c3                   	ret    

000003fc <sbrk>:
 3fc:	b8 13 00 00 00       	mov    $0x13,%eax
 401:	cd 40                	int    $0x40
 403:	c3                   	ret    

00000404 <sleep>:
 404:	b8 14 00 00 00       	mov    $0x14,%eax
 409:	cd 40                	int    $0x40
 40b:	c3                   	ret    
 40c:	90                   	nop
 40d:	90                   	nop
 40e:	90                   	nop
 40f:	90                   	nop

00000410 <putc>:
#include "stat.h"
#include "user.h"

static void
putc(int fd, char c)
{
 410:	83 ec 2c             	sub    $0x2c,%esp
 413:	88 54 24 1c          	mov    %dl,0x1c(%esp)
  write(fd, &c, 1);
 417:	8d 54 24 1c          	lea    0x1c(%esp),%edx
 41b:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
 422:	00 
 423:	89 54 24 04          	mov    %edx,0x4(%esp)
 427:	89 04 24             	mov    %eax,(%esp)
 42a:	e8 65 ff ff ff       	call   394 <write>
}
 42f:	83 c4 2c             	add    $0x2c,%esp
 432:	c3                   	ret    
 433:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
 439:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000440 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 440:	57                   	push   %edi
 441:	56                   	push   %esi
 442:	53                   	push   %ebx
 443:	89 c3                	mov    %eax,%ebx
 445:	83 ec 10             	sub    $0x10,%esp
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 448:	8b 44 24 20          	mov    0x20(%esp),%eax
 44c:	85 c0                	test   %eax,%eax
 44e:	74 60                	je     4b0 <printint+0x70>
 450:	89 d0                	mov    %edx,%eax
 452:	c1 e8 1f             	shr    $0x1f,%eax
 455:	84 c0                	test   %al,%al
 457:	74 57                	je     4b0 <printint+0x70>
    neg = 1;
    x = -xx;
 459:	89 d0                	mov    %edx,%eax
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
 45b:	bf 01 00 00 00       	mov    $0x1,%edi
    x = -xx;
 460:	f7 d8                	neg    %eax
  } else {
    x = xx;
  }

  i = 0;
 462:	31 f6                	xor    %esi,%esi
 464:	eb 04                	jmp    46a <printint+0x2a>
 466:	66 90                	xchg   %ax,%ax
  do{
    buf[i++] = digits[x % base];
 468:	89 d6                	mov    %edx,%esi
 46a:	31 d2                	xor    %edx,%edx
 46c:	f7 f1                	div    %ecx
 46e:	0f b6 92 dd 07 00 00 	movzbl 0x7dd(%edx),%edx
  }while((x /= base) != 0);
 475:	85 c0                	test   %eax,%eax
    x = xx;
  }

  i = 0;
  do{
    buf[i++] = digits[x % base];
 477:	88 14 34             	mov    %dl,(%esp,%esi,1)
 47a:	8d 56 01             	lea    0x1(%esi),%edx
  }while((x /= base) != 0);
 47d:	75 e9                	jne    468 <printint+0x28>
  if(neg)
 47f:	85 ff                	test   %edi,%edi
 481:	74 07                	je     48a <printint+0x4a>
    buf[i++] = '-';
 483:	c6 04 14 2d          	movb   $0x2d,(%esp,%edx,1)
 487:	8d 56 02             	lea    0x2(%esi),%edx

  while(--i >= 0)
 48a:	8d 72 ff             	lea    -0x1(%edx),%esi
 48d:	8d 76 00             	lea    0x0(%esi),%esi
    putc(fd, buf[i]);
 490:	0f be 14 34          	movsbl (%esp,%esi,1),%edx
 494:	89 d8                	mov    %ebx,%eax
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 496:	83 ee 01             	sub    $0x1,%esi
    putc(fd, buf[i]);
 499:	e8 72 ff ff ff       	call   410 <putc>
    buf[i++] = digits[x % base];
  }while((x /= base) != 0);
  if(neg)
    buf[i++] = '-';

  while(--i >= 0)
 49e:	83 fe ff             	cmp    $0xffffffff,%esi
 4a1:	75 ed                	jne    490 <printint+0x50>
    putc(fd, buf[i]);
}
 4a3:	83 c4 10             	add    $0x10,%esp
 4a6:	5b                   	pop    %ebx
 4a7:	5e                   	pop    %esi
 4a8:	5f                   	pop    %edi
 4a9:	c3                   	ret    
 4aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  neg = 0;
  if(sgn && xx < 0){
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 4b0:	89 d0                	mov    %edx,%eax
  static char digits[] = "0123456789ABCDEF";
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
 4b2:	31 ff                	xor    %edi,%edi
 4b4:	eb ac                	jmp    462 <printint+0x22>
 4b6:	8d 76 00             	lea    0x0(%esi),%esi
 4b9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000004c0 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 4c0:	55                   	push   %ebp
 4c1:	57                   	push   %edi
 4c2:	56                   	push   %esi
 4c3:	53                   	push   %ebx
 4c4:	83 ec 2c             	sub    $0x2c,%esp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4c7:	8b 5c 24 44          	mov    0x44(%esp),%ebx
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
 4cb:	8b 6c 24 40          	mov    0x40(%esp),%ebp
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4cf:	0f b6 0b             	movzbl (%ebx),%ecx
 4d2:	84 c9                	test   %cl,%cl
 4d4:	0f 84 86 00 00 00    	je     560 <printf+0xa0>
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
 4da:	8d 44 24 48          	lea    0x48(%esp),%eax
{
  char *s;
  int c, i, state;
  uint *ap;

  state = 0;
 4de:	31 f6                	xor    %esi,%esi
  ap = (uint*)(void*)&fmt + 1;
 4e0:	89 44 24 1c          	mov    %eax,0x1c(%esp)
 4e4:	eb 1b                	jmp    501 <printf+0x41>
 4e6:	66 90                	xchg   %ax,%ax
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
 4e8:	83 f9 25             	cmp    $0x25,%ecx
 4eb:	74 7b                	je     568 <printf+0xa8>
        state = '%';
      } else {
        putc(fd, c);
 4ed:	0f be d1             	movsbl %cl,%edx
 4f0:	89 e8                	mov    %ebp,%eax
 4f2:	e8 19 ff ff ff       	call   410 <putc>
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 4f7:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 4fa:	0f b6 0b             	movzbl (%ebx),%ecx
 4fd:	84 c9                	test   %cl,%cl
 4ff:	74 5f                	je     560 <printf+0xa0>
    c = fmt[i] & 0xff;
    if(state == 0){
 501:	85 f6                	test   %esi,%esi
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
 503:	0f b6 c9             	movzbl %cl,%ecx
    if(state == 0){
 506:	74 e0                	je     4e8 <printf+0x28>
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 508:	83 fe 25             	cmp    $0x25,%esi
 50b:	75 ea                	jne    4f7 <printf+0x37>
      if(c == 'd'){
 50d:	83 f9 64             	cmp    $0x64,%ecx
 510:	0f 84 ba 00 00 00    	je     5d0 <printf+0x110>
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
 516:	83 f9 70             	cmp    $0x70,%ecx
 519:	74 55                	je     570 <printf+0xb0>
 51b:	83 f9 78             	cmp    $0x78,%ecx
 51e:	66 90                	xchg   %ax,%ax
 520:	74 4e                	je     570 <printf+0xb0>
        printint(fd, *ap, 16, 0);
        ap++;
      } else if(c == 's'){
 522:	83 f9 73             	cmp    $0x73,%ecx
 525:	74 71                	je     598 <printf+0xd8>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
 527:	83 f9 63             	cmp    $0x63,%ecx
 52a:	0f 84 c3 00 00 00    	je     5f3 <printf+0x133>
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 530:	83 f9 25             	cmp    $0x25,%ecx
        putc(fd, c);
 533:	ba 25 00 00 00       	mov    $0x25,%edx
 538:	89 e8                	mov    %ebp,%eax
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
        ap++;
      } else if(c == '%'){
 53a:	74 12                	je     54e <printf+0x8e>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
 53c:	89 4c 24 18          	mov    %ecx,0x18(%esp)
 540:	e8 cb fe ff ff       	call   410 <putc>
        putc(fd, c);
 545:	8b 4c 24 18          	mov    0x18(%esp),%ecx
 549:	89 e8                	mov    %ebp,%eax
 54b:	0f be d1             	movsbl %cl,%edx
 54e:	e8 bd fe ff ff       	call   410 <putc>
      }
      state = 0;
 553:	31 f6                	xor    %esi,%esi
      } else if(c == '%'){
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
 555:	83 c3 01             	add    $0x1,%ebx
  int c, i, state;
  uint *ap;

  state = 0;
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
 558:	0f b6 0b             	movzbl (%ebx),%ecx
 55b:	84 c9                	test   %cl,%cl
 55d:	75 a2                	jne    501 <printf+0x41>
 55f:	90                   	nop
        putc(fd, c);
      }
      state = 0;
    }
  }
}
 560:	83 c4 2c             	add    $0x2c,%esp
 563:	5b                   	pop    %ebx
 564:	5e                   	pop    %esi
 565:	5f                   	pop    %edi
 566:	5d                   	pop    %ebp
 567:	c3                   	ret    
  ap = (uint*)(void*)&fmt + 1;
  for(i = 0; fmt[i]; i++){
    c = fmt[i] & 0xff;
    if(state == 0){
      if(c == '%'){
        state = '%';
 568:	be 25 00 00 00       	mov    $0x25,%esi
 56d:	eb 88                	jmp    4f7 <printf+0x37>
 56f:	90                   	nop
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 570:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 574:	b9 10 00 00 00       	mov    $0x10,%ecx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 579:	31 f6                	xor    %esi,%esi
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
        ap++;
      } else if(c == 'x' || c == 'p'){
        printint(fd, *ap, 16, 0);
 57b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
 582:	8b 10                	mov    (%eax),%edx
 584:	89 e8                	mov    %ebp,%eax
 586:	e8 b5 fe ff ff       	call   440 <printint>
        ap++;
 58b:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 590:	e9 62 ff ff ff       	jmp    4f7 <printf+0x37>
 595:	8d 76 00             	lea    0x0(%esi),%esi
      } else if(c == 's'){
        s = (char*)*ap;
 598:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 59c:	8b 38                	mov    (%eax),%edi
        ap++;
 59e:	83 c0 04             	add    $0x4,%eax
 5a1:	89 44 24 1c          	mov    %eax,0x1c(%esp)
        if(s == 0)
 5a5:	85 ff                	test   %edi,%edi
 5a7:	74 64                	je     60d <printf+0x14d>
          s = "(null)";
        while(*s != 0){
 5a9:	0f b6 17             	movzbl (%edi),%edx
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5ac:	31 f6                	xor    %esi,%esi
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 5ae:	84 d2                	test   %dl,%dl
 5b0:	0f 84 41 ff ff ff    	je     4f7 <printf+0x37>
 5b6:	66 90                	xchg   %ax,%ax
          putc(fd, *s);
 5b8:	0f be d2             	movsbl %dl,%edx
          s++;
 5bb:	83 c7 01             	add    $0x1,%edi
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
 5be:	89 e8                	mov    %ebp,%eax
 5c0:	e8 4b fe ff ff       	call   410 <putc>
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 5c5:	0f b6 17             	movzbl (%edi),%edx
 5c8:	84 d2                	test   %dl,%dl
 5ca:	75 ec                	jne    5b8 <printf+0xf8>
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5cc:	31 f6                	xor    %esi,%esi
 5ce:	eb 85                	jmp    555 <printf+0x95>
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 5d0:	8b 44 24 1c          	mov    0x1c(%esp),%eax
 5d4:	b1 0a                	mov    $0xa,%cl
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5d6:	66 31 f6             	xor    %si,%si
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
      if(c == 'd'){
        printint(fd, *ap, 10, 1);
 5d9:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
 5e0:	8b 10                	mov    (%eax),%edx
 5e2:	89 e8                	mov    %ebp,%eax
 5e4:	e8 57 fe ff ff       	call   440 <printint>
        ap++;
 5e9:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 5ee:	e9 04 ff ff ff       	jmp    4f7 <printf+0x37>
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 5f3:	8b 44 24 1c          	mov    0x1c(%esp),%eax
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 5f7:	31 f6                	xor    %esi,%esi
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
        putc(fd, *ap);
 5f9:	0f be 10             	movsbl (%eax),%edx
 5fc:	89 e8                	mov    %ebp,%eax
 5fe:	e8 0d fe ff ff       	call   410 <putc>
        ap++;
 603:	83 44 24 1c 04       	addl   $0x4,0x1c(%esp)
 608:	e9 ea fe ff ff       	jmp    4f7 <printf+0x37>
        ap++;
      } else if(c == 's'){
        s = (char*)*ap;
        ap++;
        if(s == 0)
          s = "(null)";
 60d:	bf d6 07 00 00       	mov    $0x7d6,%edi
 612:	eb 95                	jmp    5a9 <printf+0xe9>
 614:	90                   	nop
 615:	90                   	nop
 616:	90                   	nop
 617:	90                   	nop
 618:	90                   	nop
 619:	90                   	nop
 61a:	90                   	nop
 61b:	90                   	nop
 61c:	90                   	nop
 61d:	90                   	nop
 61e:	90                   	nop
 61f:	90                   	nop

00000620 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 620:	57                   	push   %edi
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 621:	a1 90 0a 00 00       	mov    0xa90,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
 626:	56                   	push   %esi
 627:	53                   	push   %ebx
 628:	8b 5c 24 10          	mov    0x10(%esp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
 62c:	8d 4b f8             	lea    -0x8(%ebx),%ecx
 62f:	90                   	nop
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 630:	39 c8                	cmp    %ecx,%eax
 632:	8b 10                	mov    (%eax),%edx
 634:	73 04                	jae    63a <free+0x1a>
 636:	39 d1                	cmp    %edx,%ecx
 638:	72 16                	jb     650 <free+0x30>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 63a:	39 d0                	cmp    %edx,%eax
 63c:	72 08                	jb     646 <free+0x26>
 63e:	39 c8                	cmp    %ecx,%eax
 640:	72 0e                	jb     650 <free+0x30>
 642:	39 d1                	cmp    %edx,%ecx
 644:	72 0a                	jb     650 <free+0x30>
static Header base;
static Header *freep;

void
free(void *ap)
{
 646:	89 d0                	mov    %edx,%eax
 648:	eb e6                	jmp    630 <free+0x10>
 64a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
 650:	8b 73 fc             	mov    -0x4(%ebx),%esi
 653:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
 656:	39 d7                	cmp    %edx,%edi
 658:	74 18                	je     672 <free+0x52>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
 65a:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
 65d:	8b 50 04             	mov    0x4(%eax),%edx
 660:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 663:	39 f1                	cmp    %esi,%ecx
 665:	74 22                	je     689 <free+0x69>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
 667:	89 08                	mov    %ecx,(%eax)
  freep = p;
 669:	a3 90 0a 00 00       	mov    %eax,0xa90
}
 66e:	5b                   	pop    %ebx
 66f:	5e                   	pop    %esi
 670:	5f                   	pop    %edi
 671:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 672:	03 72 04             	add    0x4(%edx),%esi
 675:	89 73 fc             	mov    %esi,-0x4(%ebx)
    bp->s.ptr = p->s.ptr->s.ptr;
 678:	8b 10                	mov    (%eax),%edx
 67a:	8b 12                	mov    (%edx),%edx
 67c:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
 67f:	8b 50 04             	mov    0x4(%eax),%edx
 682:	8d 34 d0             	lea    (%eax,%edx,8),%esi
 685:	39 f1                	cmp    %esi,%ecx
 687:	75 de                	jne    667 <free+0x47>
    p->s.size += bp->s.size;
 689:	03 53 fc             	add    -0x4(%ebx),%edx
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
  freep = p;
 68c:	a3 90 0a 00 00       	mov    %eax,0xa90
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 691:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
 694:	8b 53 f8             	mov    -0x8(%ebx),%edx
 697:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
}
 699:	5b                   	pop    %ebx
 69a:	5e                   	pop    %esi
 69b:	5f                   	pop    %edi
 69c:	c3                   	ret    
 69d:	8d 76 00             	lea    0x0(%esi),%esi

000006a0 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 6a0:	57                   	push   %edi
 6a1:	56                   	push   %esi
 6a2:	53                   	push   %ebx
 6a3:	83 ec 10             	sub    $0x10,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
 6a6:	8b 15 90 0a 00 00    	mov    0xa90,%edx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 6ac:	8b 5c 24 20          	mov    0x20(%esp),%ebx
 6b0:	83 c3 07             	add    $0x7,%ebx
 6b3:	c1 eb 03             	shr    $0x3,%ebx
 6b6:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
 6b9:	85 d2                	test   %edx,%edx
 6bb:	0f 84 9d 00 00 00    	je     75e <malloc+0xbe>
 6c1:	8b 02                	mov    (%edx),%eax
 6c3:	8b 48 04             	mov    0x4(%eax),%ecx
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
 6c6:	39 d9                	cmp    %ebx,%ecx
 6c8:	73 6e                	jae    738 <malloc+0x98>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 6ca:	8d 3c dd 00 00 00 00 	lea    0x0(,%ebx,8),%edi
 6d1:	eb 0e                	jmp    6e1 <malloc+0x41>
 6d3:	90                   	nop
 6d4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 6d8:	8b 02                	mov    (%edx),%eax
    if(p->s.size >= nunits){
 6da:	8b 48 04             	mov    0x4(%eax),%ecx
 6dd:	39 cb                	cmp    %ecx,%ebx
 6df:	76 57                	jbe    738 <malloc+0x98>
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
 6e1:	3b 05 90 0a 00 00    	cmp    0xa90,%eax
 6e7:	89 c2                	mov    %eax,%edx
 6e9:	75 ed                	jne    6d8 <malloc+0x38>
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 6eb:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
 6f1:	b8 00 80 00 00       	mov    $0x8000,%eax
    nu = PAGE;
 6f6:	be 00 10 00 00       	mov    $0x1000,%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < PAGE)
 6fb:	76 04                	jbe    701 <malloc+0x61>
 6fd:	89 f8                	mov    %edi,%eax
 6ff:	89 de                	mov    %ebx,%esi
    nu = PAGE;
  p = sbrk(nu * sizeof(Header));
 701:	89 04 24             	mov    %eax,(%esp)
 704:	e8 f3 fc ff ff       	call   3fc <sbrk>
  if(p == (char*) -1)
 709:	83 f8 ff             	cmp    $0xffffffff,%eax
 70c:	74 1a                	je     728 <malloc+0x88>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
 70e:	89 70 04             	mov    %esi,0x4(%eax)
  free((void*)(hp + 1));
 711:	83 c0 08             	add    $0x8,%eax
 714:	89 04 24             	mov    %eax,(%esp)
 717:	e8 04 ff ff ff       	call   620 <free>
  return freep;
 71c:	8b 15 90 0a 00 00    	mov    0xa90,%edx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
 722:	85 d2                	test   %edx,%edx
 724:	75 b2                	jne    6d8 <malloc+0x38>
 726:	66 90                	xchg   %ax,%ax
        return 0;
  }
}
 728:	83 c4 10             	add    $0x10,%esp
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
 72b:	31 c0                	xor    %eax,%eax
  }
}
 72d:	5b                   	pop    %ebx
 72e:	5e                   	pop    %esi
 72f:	5f                   	pop    %edi
 730:	c3                   	ret    
 731:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
 738:	39 cb                	cmp    %ecx,%ebx
 73a:	74 1c                	je     758 <malloc+0xb8>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
 73c:	29 d9                	sub    %ebx,%ecx
 73e:	89 48 04             	mov    %ecx,0x4(%eax)
        p += p->s.size;
 741:	8d 04 c8             	lea    (%eax,%ecx,8),%eax
        p->s.size = nunits;
 744:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
 747:	89 15 90 0a 00 00    	mov    %edx,0xa90
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 74d:	83 c4 10             	add    $0x10,%esp
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
 750:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 753:	5b                   	pop    %ebx
 754:	5e                   	pop    %esi
 755:	5f                   	pop    %edi
 756:	c3                   	ret    
 757:	90                   	nop
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
 758:	8b 08                	mov    (%eax),%ecx
 75a:	89 0a                	mov    %ecx,(%edx)
 75c:	eb e9                	jmp    747 <malloc+0xa7>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 75e:	c7 05 90 0a 00 00 94 	movl   $0xa94,0xa90
 765:	0a 00 00 
    base.s.size = 0;
 768:	b8 94 0a 00 00       	mov    $0xa94,%eax
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
 76d:	c7 05 94 0a 00 00 94 	movl   $0xa94,0xa94
 774:	0a 00 00 
    base.s.size = 0;
 777:	c7 05 98 0a 00 00 00 	movl   $0x0,0xa98
 77e:	00 00 00 
 781:	e9 44 ff ff ff       	jmp    6ca <malloc+0x2a>
